import axios from 'axios';

function getUsers () {
    return axios.get('/api/users/list');
}
export default {
    namespace: 'users',
    state: [{id: 0, name: '张三', age: 11}],
    effects: {
        *getUsers (action, {call, put}) {
            const res = yield call(getUsers);
            console.log('获取到数据: ', res);
            yield put({
                type: 'init', 
                payload: res.data
            });
        }
    },
    reducers: {
        init (state, {payload}) {
            return payload;
        }
    }
}